<%--
    Document   : Corsi_Studente
    Created on : 28-apr-2012, 16.39.00
    Author     : Daniel
--%>

<%@page import="Utils.CorsoPlan"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="Utils.Corso_base "%>
<%@page import="Utils.Corso "%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Corsi</title>

<link rel="stylesheet" type="text/css" href="css/bootstrap.css"> <!-- Chiamata al css contenente la grafica -->
<link rel="stylesheet" type="text/css" href="css/smoothness/jquery-ui-1.8.19.custom.css" >
<script src="js/jquery-1.7.2.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script type="text/javascript" src="js/jquery-ui-1.8.19.custom.min.js" ></script>

 <style type="text/css">
        #selectable .ui-selecting { background: #FFFFFF; }
	#selectable .ui-selected { background: #99CBFF; color: black; border: #34FF12; }
</style>

            <jsp:useBean id="result" scope="request" class="java.util.List <Corso> "></jsp:useBean>
            
            <jsp:useBean id="corso" scope="request" class="Utils.Corso" ></jsp:useBean>
            
            <jsp:useBean id="plan" scope="request" type="Utils.StudyPlan"></jsp:useBean>
    
            <jsp:useBean id="error" scope="request" type="java.lang.String"></jsp:useBean>
            

<script type="text/javascript">
	$(function() {
		$("#selectable").selectable(
                { filter : 'tr',                 
                  stop: function() 
                    {
                        
                        str = ($(".ui-selected",this).attr("id"));
                            if(str.match("Row-0"))
                                    $(".ui-selected",this).removeClass("ui-selected");
                            else
                                {
                                document.location.href = "Corsi_Studente?corso_sel="+(get_selected_index()-1);                                 
                                }
			$(".ui-selected",this).each(function() {
                               $(this).siblings().removeClass("ui-selected");         
		     })}})
	});
        
       function get_selected_index(){
         var elim = document.getElementById(str);
         var x = elim.rowIndex;
         return x;
       }
 
</script>

<script>
            $(document).ready(function (){
                var x = $(document).height();
                $('#Bottom_bar').css("top", (x+118)+"px");
                $('#Menu_background').css("height" , x+"px");
            });

</script> 

</head>
<body>
      
<div id="Top_bar"> </div>
<div id="Bottom_bar"> </div>

<div id="Header">

	<div id="LOGO_UNITN" class="image" style="position:absolute;left:26px;top:15px;width:339px;height:93px;z-index:0;padding:0;">
	<img src="images/logo_unitn1.gif" id="Image1" alt="" border="0" style="width:339px;height:93px;"></div>
        
</div>

<div>
    <div id="Menu_background" > </div>
<div id="SlideMenu1">
<ul class="nav nav-list">
  <li class="nav-header">
    studente
  </li>
  <li>
    <a href="Home_Studente">Home</a>
  </li>
  <li>
    <a href="Study_Plan">Study Plan</a>
  </li>
  <li class="active">
    <a href="Corsi_Studente">Corsi</a>
  </li>
  <li>
    <a href="Logout">Logout</a>
  </li>
</ul>
</div> 

<div class="modal fade" id="myModal">
            <div class="modal-header">
            <button class="close" data-dismiss="modal">×</button>
            <h3>Richiesta inserimento corso esterno</h3>
            </div>  
            <div class="modal-body">
                <form class="form-horizontal" method="post" action="mailing">
                <fieldset>
                    <div class="control-group">
                        <label class="control-label" for="nome_corso">Nome corso*</label>
                        <div class="controls">
                        <input type="text" class="input-xlarge " id="nome_corso">
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label" for="periodo">Periodo*</label>
                        <div class="controls">
                            <input type="text" class="input-xlarge" id="periodo">
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label" for="docente">Docente*</label>
                        <div class="controls">
                        <input type="text" class="input-xlarge " id="docente" >
                        </div>
                    </div>
                    <div class="control-group">
                          <label class="control-label" for="email">Email docente*</label>
                          <div class="controls">
                          <input type="text" class="input-xlarge" id="email"> 
                      </div>
                     </div>
                    <div class="control-group">
                        <label class="control-label" for="url">Url al corso*</label>
                        <div class="controls">
                          <input type="text" class="input-xlarge" id="url"> 
                        <p class="help-block">Le informazioni con * sono obbligatorie</p>
                        </div>
                     </div>
                     <div class="form-actions">
                        <button type="submit" class="btn btn-primary">Invia richiesta</button>
                        <button class="btn btn-danger" data-dismiss="modal" >Cancel</button>
                     </div>
                 </fieldset>
                </form>
             </div>
        </div> 
   

       
<div id="wb_Text3" style="position:absolute;left:190px;top:162px">
    <h3>Elenco Corsi</h3>
</div>

<div id="wb_Text7" style="position:absolute;left:573px;top:162px">
    <h3>Informazioni corso selezionato:</h3>
</div>

 <button class="btn" data-toggle="modal" style="position:absolute;left:965px;top:635px;" data-target = "#myModal">Inserisci corso esterno</button>            
    
<% 
if(request.getParameter("corso_sel") != null)
{
  int id = corso.getId();
    
%>
<form method = "get" action = "Corsi_Studente" style="position:absolute;left:569px;top:620px;">
    <input type="hidden" name="corso_sel" value="<% out.append(""+request.getParameter("corso_sel"));  %>">
    <h5>
    <%
    out.append(error);
    %>
    </h5>
    <br>
    <% if(!plan.contiene(id)) 
           {
    %>
    <input class="btn" type="submit" name="operazione"  value="Aggiungi al plan"><br><br>
    <%
           }
    else
           {
    %>
    <input class="btn" type="submit" name="operazione"  value="Rimuovi dal plan"><br><br>
    <%
           }
    %>

</form>
<%
;}
%> 
    
    
<form method = "post" action = "Corsi_Studente">
    
<input class="input-large search-query" type="text" id="edit_cerca" style="position:absolute;left:190px;top:190px" name="corso_nome">
<input class="btn" type="submit" id="button_cerca" name="button_cerca" value="Cerca" style="position:absolute;left:440px;top:190px">

</form>   

<div style="position:absolute;left:190px;top:230px;width:345px;height:600px;overflow:auto;">
<table id="selectable" class="table table-bordered">
<tr id ="Row-0" class="table_header">
    <th>
        Risultato Query
    </th>
</tr>
<c:forEach items="${result}" var="course">
                        <tr id="${course.id}">
                        <td style="cursor: pointer"><c:out value="${course.nome}"/></td>
                        </tr>            
</c:forEach>
</table>
</div> 

<table class="table table-bordered" style="position:absolute;left:569px;top:190px;width:550px;height:225px" id="table_corsi">

<tr>
<th colspan="2">Informazioni corso</th>
</tr>

<tr>
<td style="width:160px">Nome Corso</td>
<td ><jsp:getProperty name = "corso" property="nome"></jsp:getProperty></td>
</tr>

<tr>
<td>Periodo</td>
<td><jsp:getProperty name = "corso" property="periodo"></jsp:getProperty></td>
</tr>

<tr>
<td>Crediti</td>
<td><jsp:getProperty name = "corso" property="crediti"></jsp:getProperty></td>
</tr>

<tr>
<td>Data inizio lezioni
</td>
<td><jsp:getProperty name = "corso" property="data_inizio"></jsp:getProperty></td>
</tr>

<tr>
<td>Aula lezioni</td>
<td><jsp:getProperty name = "corso" property="aula_lezioni"></jsp:getProperty></td>
</tr>

<tr>
<td>Numero iscritti
</td>
<td><jsp:getProperty name = "corso" property="numero_iscritti"></jsp:getProperty></td>
</tr>

<tr>
<td>Tipo</td>
<td>                   <%
                            if(!("".equals(corso.getNome()))) 
                               if(corso.isEsterno())
                                   out.append("Esterno");
                               else
                                   out.append("Interno");
                            else
                                   out.append("");
        
                        %></td>
</tr>

<tr>
<td>Url al corso</td>
<td><jsp:getProperty name = "corso" property="url_corso"></jsp:getProperty></td>
</tr>

<tr>
<td>Nome del docente</td>
<td class="table_cell"><jsp:getProperty name = "corso" property="docente"></jsp:getProperty></td>
</tr>

<tr>
<td>Email del docente</td>
<td><jsp:getProperty name = "corso" property="email"></jsp:getProperty></td>
</tr>

<tr>
<td>Note del docente</td>
<td><jsp:getProperty name = "corso" property="note"></jsp:getProperty></td>
</tr>

</table>
</div>
</body>
</html>